#include <memory>
#include <verilated.h>
#include "VTOP.h"
#include "verilated_vcd_c.h"
int main(int argc, char** argv){
	const std::unique_ptr<VerilatedContext> contextp{new VerilatedContext};
	contextp->traceEverOn(true);
	contextp->commandArgs(argc,argv);
	VerilatedVcdC* tfp=new VerilatedVcdC;
	const std::unique_ptr<VTOP> top{new VTOP{contextp.get(),"TOP"}};
	top->trace(tfp, 99);
	tfp->open("waveform.vcd");

	top->rst_n=0;
	top->clk=0;

	while(!contextp->gotFinish()&&contextp->time()<20){
		if(contextp->time()==2){
			top->rst_n=1;
		} else if(contextp->time()==4){
			top->in_wr=1;
			top->in_wdata=10;
			top->in_rd=0;
		} else if(contextp->time()==6){
			top->in_wr=0;
			top->in_rd=1;
		} else if(contextp->time()==8){
			top->in_wr=1;
			top->in_wdata=11;
			top->in_rd=0;
		} else if(contextp->time()==10){
			top->in_wdata=12;
		} else if(contextp->time()==12){
			top->in_wr=0;
			top->in_rd=1;
		} 
		top->clk=!top->clk;
		top->eval();
		tfp->dump(contextp->time());
		contextp->timeInc(1);
	}
	top->final();
	tfp->close();
	return 0;
}
